class BarangsController < ApplicationController
  # GET /barangs
  # GET /barangs.json
  
  layout'Transaksi_layout'
  
  def index
    
    @barangs = Barang.limit(10)
    
    respond_to do |format|
      format.html # index.html.erb
      format.json { render json: @barangs }
    end
  end

  # GET /barangs/1
  # GET /barangs/1.json
  def show
    @barang = Barang.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.json { render json: @barang }
    end
  end

  # GET /barangs/new
  # GET /barangs/new.json
  def new
    @barang = Barang.new

    respond_to do |format|
      format.html # new.html.erb
      format.json { render json: @barang }
    end
  end

  # GET /barangs/1/edit
  def edit
    @barang = Barang.find(params[:id])
  end

  # POST /barangs
  # POST /barangs.json
  def create
    @barang = Barang.new(params[:barang])

    respond_to do |format|
      if @barang.save
        format.html { redirect_to @barang, notice: 'Barang was successfully created.' }
        format.json { render json: @barang, status: :created, location: @barang }
      else
        format.html { render action: "new" }
        format.json { render json: @barang.errors, status: :unprocessable_entity }
      end
    end
  end

  # PUT /barangs/1
  # PUT /barangs/1.json
  def update
    @barang = Barang.find(params[:id])

    respond_to do |format|
      if @barang.update_attributes(params[:barang])
        format.html { redirect_to @barang, notice: 'Barang was successfully updated.' }
        format.json { head :ok }
      else
        format.html { render action: "edit" }
        format.json { render json: @barang.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /barangs/1
  # DELETE /barangs/1.json
  def destroy
    @barang = Barang.find(params[:id])
    @barang.destroy

    respond_to do |format|
      format.html { redirect_to barangs_url }
      format.json { head :ok }
    end
  end
  

  
end
